﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Caching;

namespace Xyz.Framework.Server.Caching
{
    public class Cache
    {
        private ObjectCache _cache;
        private static Cache _current;

        private Cache()
        {
            _cache = MemoryCache.Default;
        }

        public object Get(string key)
        {
            return _cache.Get(key);
        }

        public void Set(string key, object value)
        {
            _cache.Set(key, value, System.Runtime.Caching.ObjectCache.InfiniteAbsoluteExpiration);
        }

        public void Remove(string key)
        {
            _cache.Remove(key);
        }

        //singelton
        public static Cache Current
        {
            get
            {
                if (_current == null)
                {
                    _current = new Cache();
                }
                return _current;
            }
        }




    }
}
